<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\goods\model;

use think\Model;

/**
 * 标签
 */
class Tag extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__GOODS_TAG__';

    public static function getAll()
    {
        $data = array();
        $data = cache('tag_data');
        if(empty($data)){
	        $list = self::all();
	        foreach($list as $d)
	        {	
	        	if($d['status'] == 1){
	            $k = $d['tagid'];
	            $data[$k] = $d->getData();
	        }
	        }
	       	cache('tag_data',$data);
    	}
        return $data;
    }

    public function getTags($where = ''){
    	$tag_data = [];
		$tags = [];
		$tag_all = self::getall();
		$tags = explode(',', trim($where,','));
		foreach ($tags as $k => $val) {
			$tag_data[] = $tag_all[$val];
		}
		return $tag_data;
    }
    
}